<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <link rel="stylesheet" href="/layui/css/layui.css">
    <script src="/layui/layui.js"></script>
    <script src="/js/jquery-3.3.1.min.js"></script>

    <script src="/ueditor/third-party/jquery-1.10.2.js"></script>
    <!-- 配置文件 -->
    <script src="/ueditor/ueditor.config.js"></script>
    <!-- 编辑器源码文件 -->
    <script src="/ueditor/ueditor.all.js"></script>
    <script src="/ueditor/lang/zh-cn/zh-cn.js"></script>
    <script src="/ueditor/ueditor.parse.js"></script>

</head>
<body>
<ul class="layui-nav layui-nav-tree layui-nav-side" lay-filter="demo">
    <li class="layui-nav-item">
        <a href="/index">发帖</a>
    </li>
    <li class="layui-nav-item">
        <a href="/detail">查看帖子</a>
    </li>
    <li class="layui-nav-item"><a href="/ueditor">UEditor</a></li>
</ul>
<div class="layui-row layui-form" style="margin-left: 250px;">
    <div style="margin-top: 40px; width: 500px;">
        <span th:text="${id}" id="id" style="display: none;"></span>
        <label for="L_title" class="layui-form-label" style="background-color: #00F7DE">标题</label>
        <div class="layui-input-block">
            <input type="text" id="L_title" name="title" required lay-verify="required"
                   autocomplete="off" class="layui-input">
        </div>
    </div>
    <div style="margin-top: 20px;margin-right: 150px;" id="content">

    </div>
</div>
<script type="application/javascript">

    layui.use('form', function () {
        var $ = layui.jquery;

        //ajax提交信息
        $.ajax({
            type: "get",
            async: false,
            url: "/forum/get_forum_by_id?id=" + document.getElementById("id").innerText,
            dataType: 'json',
            success: function (msg) {
                console.log(msg);
                document.getElementById("L_title").value = msg.data.title;
                let content = document.getElementById("content");
                content.innerHTML = msg.data.content;
            },
            error: function (msg) {
                // 请求失败时执行该函数
                layer.alert('请求数据失败！！！', function (index) {
                    //do something
                    layer.close(index);
                });
            }
        });

        return false;
    });
</script>
</body>
</html>